﻿@model List<Input>

@section styles{
    @Styles.Render("~/Content/bootstrap-select.css")
    @Styles.Render("~/Content/daterangepicker-bs3.css")
}

@{
    ViewBag.Title = "Thống kê nhập liệu";

    string controller = "input";

    string dateRange = ViewBag.DateRange ?? "";
}

<section class="content-header">
    <h1>
        NHẬP LIỆU <small>thống kê</small>
    </h1>
    <ol class="breadcrumb">
        <li>
            <a href="@Url.Action("Index", "Admin")">
                <i class="fa fa-home"></i> Trang chủ
            </a>
        </li>
        <li class="active">Thống kê nhập liệu</li>
    </ol>
</section>

<section class="content">
    <div class="box">
        <div class="box-body">
            <div class="row">
                <div class="col-md-4">
                    @using (Html.BeginForm())
                    {
                        <div class="form-group">
                            <label class="control-label">Khoảng thời gian</label>
                            <div class="input-group">
                                @Html.TextBox("DateRange", dateRange, new { @class = "form-control", @readonly = "readonly", style = "cursor: pointer" })
                                <span class="input-group-btn">
                                    <button class="btn btn-primary" type="submit">Duyệt</button>
                                </span>
                            </div>
                        </div>
                    }
                    <table class="table table-bordered table-details">
                        @foreach (var item in Model.GroupBy(x => x.Name))
                        {
                            <tr>
                                <th>@item.Key</th>
                                <td>@item.Count() sản phẩm</td>
                            </tr>
                        }
                    </table>
                </div>
                <div class="col-md-4" style="border-left: 1px solid #ddd;">
                    <div style="height: 580px; overflow-y: scroll">
                        @foreach (var item in Model.GroupBy(x => x.Date.Date))
                        {
                            <h4 class="text-primary">
                                @item.Key.ToString("dd/MM/yyyy")
                            </h4>
                            foreach (var item2 in Model.Where(x => x.Date.Date == item.Key).GroupBy(x => x.Name))
                            {
                                <p><b>@item2.Key</b>: @item2.Count() sản phẩm</p>
                            }
                            <hr />
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>



@section scripts{
    @Scripts.Render("~/Scripts/daterangepicker/daterangepicker.js")
    @Scripts.Render("~/Scripts/daterangepicker/moment.js")
    <script>
        $('#DateRange').daterangepicker({
            timePicker: false,
            format: 'DD/MM/YYYY',
            locale: {
                applyLabel: 'Xác nhận',
                cancelLabel: 'Đóng',
                fromLabel: 'Từ',
                toLabel: 'Đến',
            }
        });

        ActiveMenu('@controller');
    </script>
}